# -*- coding: utf-8 -*-

import functools
import importlib


@functools.cache
def import_class(class_path):
    mod_cls = class_path.rsplit(".", maxsplit=1)
    if len(mod_cls) == 2:
        mod, cls = mod_cls
        mod = mod or "."
    else:
        mod = "."
        cls = mod_cls[0]

    mod = importlib.import_module(mod)
    return getattr(mod, cls)
